#define _CRT_SECURE_NO_WARNINGS

#include "Heap.h"

void test1()
{
	Heap hp;
	HeapInit(&hp);

	HeapPush(&hp, 22);
	HeapPush(&hp, 122);
	HeapPush(&hp, 16);
	HeapPush(&hp, 45);
	HeapPush(&hp, 56);
	HeapPush(&hp, 18);
	HeapPush(&hp, 134);
	HeapPush(&hp, 99);

	HeapDestroy(&hp);
}

void test2()
{
	Heap hp;
	HeapInit(&hp);

	int arr[] = { 34,113,78,44,98,99,35,26,18,68 };
	int n = sizeof(arr) / sizeof(arr[0]);
	HeapCreateArray(&hp, arr, n);

	while (!HeapEmpty(&hp))
	{
		printf("%d ", HeapTop(&hp));
		HeapPop(&hp);
	}
	printf("\n");

	HeapDestroy(&hp);
}

void test3()
{
	int arr[] = { 34,113,78,44,98,99,35,26,18,68 };
	int n = sizeof(arr) / sizeof(arr[0]);

	HeapSort(arr, n);

	for (int i = 0; i < n; i++) printf("%d ", arr[i]);
	printf("\n");
}

void testTopK()
{
	int arr[] = { 34,113,78,44,98,99,35,26,18,68 };
	int n = sizeof(arr) / sizeof(arr[0]);

	PrintTopK(arr, n, 5);
}

int main()
{
	//test1();
	test2();
	test3();
	testTopK();

	return 0;
}